$(function() {
	$('table.table tr:nth-child(even)').addClass('even');
	$('.server-list:first').css({'border-top': 0});
	$('ul.comments li:last').css({'border-bottom': 0});
	$('ul.notice li:last').css({'border-bottom': 0});
	$('ul.clear li:first').css({'border-top': 0});
	$('#castle_siege .detail ul li:first').css({'border-top': 0});
	$('#castle_siege .detail ul li:last').css({'border-bottom': 0});
	//$('.server-list:last').css({'border-bottom': 0});
	$('select').selectbox();
	
	$('#terms').jScrollPane();
	
	$('#panel_of_control').live('submit', function () {
		$.blockUI(block_config);
		$.ajax({
			type: 'POST',
			dataType: 'json',
			url: base + '/login',
			data: $(this).serialize(),
			success: function (data) {
				if (data.success == 1) {
					window.location = base;	
				} else {
					$.blockUI({ 
						css: block_css,
						message: data.error
					});
					$('#password').attr('value', '');
					setTimeout($.unblockUI, 3000);
				}
			}
		});
		return false;
	});
	
	$('#post_comment').live('submit', function () {
		$.blockUI(block_config);
		$.ajax({
			type: 'POST',
			dataType: 'json',
			url: base + '/post_comment',
			data: $(this).serialize(),
			success: function (data) {
				if (data.success == 1) {
					prepend = '<li><div class="avatar"><img src="' + base + data.avatar + '" width="70" height="85" /></div><div class="text"><p class="author">' + data.author + '<span class="created">5 segundos atr&aacute;s</span></p><p>' + data.body + '</p></div></li>';
					$('ul.comments').prepend(prepend);
					$('#comment').val('');
					$('body, html').animate({scrollTop: $('#comments').offset().top});
					$.unblockUI();
				} else {
					$.blockUI({ 
						css: block_css,
						message: data.error
					});
					setTimeout($.unblockUI, 3000);
				}
			}
		});		
		return false;
	});
});